package com.cdc.tools;

import com.cdc.mobileassistant.ui.bean.App;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.util.Log;

/**
 * Created by admin on 2018/4/8.
 */

public class AppsTools {
    public static  List<App> getApps(Context context){
        List<App>  appInfos=new ArrayList<App>();
        final PackageManager packageManager = context.getPackageManager();
     /*   final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);*/
//        List<ResolveInfo> apps = packageManager.queryIntentActivities(
//                mainIntent, 0);
        List<PackageInfo> packages=packageManager.getInstalledPackages (0);
        for (PackageInfo aPackage : packages) {
            Log.e("cdc",aPackage.packageName+","+packages.size()+",");
        }

        return appInfos;
    }
}
